#pragma once

typedef struct TreeNode{
	int data;
	struct TreeNode *lchild, *rchild;
	struct TreeNode* parent;
}TreeNode, *BiTree;

#define MAXSIZE 50

typedef struct {
	 TreeNode* data[MAXSIZE];
	int top;
}Stack;

void InitStack(Stack* s)
{
	s->top = -1;
}

void Push(Stack* s, TreeNode* x)
{
	if (s->top == MAXSIZE - 1)
		return;
	s->data[++s->top] = x;
}

void Pop(Stack* s)
{
	if (s->top == -1)
		return;
	s->top--;
}

TreeNode* GetTop(Stack* s)
{
	if (s->top == -1)
		return -1;
	else
		return s->data[s->top];
}

bool IsEmpty(Stack* s)
{
	if (s->top == -1)
		return true;
	else
		return false;
}

int Length(Stack* s)
{
	return s->top + 1;
}

typedef struct {
	TreeNode* data[50];
	int front, rear;
}Queue;

void Init_Queue(Queue* q)
{
	q->front = q->rear = -1;
}

bool IsEmpty_Q(Queue* q)
{
	return q->front == q->rear;
}

void EnOrder(Queue* q,TreeNode* t)
{
	q->data[++q->rear] = t;
}

TreeNode* DeOrder(Queue* q)
{
	TreeNode* p = q->data[++q->front];
	return p;
}


